<template>
  <div style="flex:1;" class="flex">
    <criteria-paged :model="model" v-ref:paged>
      <criteria partial='criteria' @condition-changed='$parent.selfSearch' v-ref:cri>
        <div novalidate class="form-inline" partial>
          <div class="form-group">
            <input  type="text" class="form-control" v-model="model.f_allowed_user" placeholder='授权用户'
                    condition="f_allowed_user like '%{}%'" v-next-el="sqyh"
                    :size="model.f_allowed_user ? model.f_.length*2 : 4">
          </div>
          <div class="form-group">
            <input  type="text" class="form-control" v-model="model.f_allowed_company" placeholder='授权公司'
                    condition="f_allowed_company like '%{}%'" v-next-el="cx" v-el:sqyh
                    :size="model.f_allowed_company ? model.f_price_name.length*2 : 4">
          </div>
          <div class="form-group">
            <button class="btn btn-success width-100" @click="$parent.$parent.search()" v-el:cx>查询</button>
          </div>
          <div class="form-group">
            <button class="btn btn-success width-100" @click="$parent.$parent.add()">新增</button>
          </div>
        </div>
      </criteria>
      <data-grid  :model="model" partial='list' v-ref:grid>
        <template partial='head'>
          <tr>
            <th v-show="false"></th>
            <th>序号</th>
            <th>授权用户名</th>
            <th>用户密码</th>
            <th>授权公司名称</th>
            <th>操作人</th>
            <th>操作时间</th>
          </tr>
        </template>
        <template partial='body'>
          <tr>
            <td v-show="false">{{row.id}}</td>
            <td style="text-align:center">{{$index+1}}</td>
            <td style="text-align:center">
              {{row.f_allowed_user}}&nbsp;
            </td>
            <td style="text-align:center">{{row.f_password}}</td>
            <td style="text-align:center">{{row.f_allowed_company}}
            </td>
            <td style="text-align:center">{{row.f_operator}}</td>
            <td style="text-align:center">{{row.f_operation_time}}</td>
            <!--<td style="text-align:center" >-->
              <!--&lt;!&ndash;<button class="btn btn-success width-26" type="button" @click="$parent.$parent.$parent.edit()">修改</button>&ndash;&gt;-->
            <!--</td>-->
          </tr>
        </template>
        <template partial='foot'></template>
      </data-grid>
    </criteria-paged>
  </div>
</template>

<script>
import { PagedList } from 'vue-client'
import * as Util from '../../../../Util'
import Vue from 'vue'
import Input from "vue-client/src/components/Input";

export default {
  name: 'HelpInfoList',
  components: {Input},
  data () {
    return {
      model: new PagedList('rs/sql/getHelpInfo', 20, {orderitem: '"' + this.orderitem + '"'}),
      filiale: ''
    }
  },
  props: {
    orderitem: {
      type: String,
      default: 'f_operation_time'
    },
    row: {}
  },
  ready () {
    this.getFiliale(Util.f.parent)
    this.search()
  },
  methods: {
    search () {
      this.$refs.paged.$refs.cri.search()
      this.$dispatch('search')
    },
    selfSearch (args) {
      args.condition = `${args.condition} and ${this.filiale}`
      this.model.search(args.condition, args.model)
    },
    add () {
      this.$dispatch('add')
    },
    edit () {
      console.log('modify执行进来啦')
      this.$dispatch('edit')
    },
    del (row) {
      this.$emit('del', row)
    },
    getFiliale (val) {
      if (val.orgtype === '总公司' || val.orgtype === '分公司') {
        if (val.orgtype === '分公司') {
          this.filiale = `s.f_filiale = '${val.name}'`
        } else {
          this.filiale = '1=1'
        }
      } else {
        this.getFiliale(val.parent)
      }
    }
  }
}
</script>

<style scoped>

</style>
